package com.bss.model;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import com.andy.basics.AbstractEntity;

@Entity
@Table(name = "passport")
public class Passport extends AbstractEntity {

	private static final long serialVersionUID = -6317473483766027802L;

	private int id;

	private String passportNumber;

	private Date dateOfIssue = new Date();

	private Date dateOfExpiry = new Date();

	private Person person;

	@NotNull(message = "{passport.passportNumber.NotNull}")
	@Size(min = 1, max = 10, message = "{passport.passportNumber.Size}")
	public String getPassportNumber() {
		return this.passportNumber;
	}

	public void setPassportNumber(String passportNumber) {
		this.passportNumber = passportNumber;
	}

	@NotNull(message = "{passport.dateOfIssue.NotNull}")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getDateOfIssue() {
		return this.dateOfIssue;
	}

	public void setDateOfIssue(Date dateOfIssue) {
		this.dateOfIssue = dateOfIssue;
	}

	@NotNull(message = "{passport.dateOfExpiry.NotNull}")
	@Temporal(TemporalType.TIMESTAMP)
	public Date getDateOfExpiry() {
		return this.dateOfExpiry;
	}

	public void setDateOfExpiry(Date dateOfExpiry) {
		this.dateOfExpiry = dateOfExpiry;
	}

	@OneToOne(fetch = FetchType.EAGER, mappedBy = "passport")
	public Person getPerson() {
		return this.person;
	}

	public void setPerson(Person person) {
		this.person = person;
	}

	@Id
	@Column(name = "id", unique = true, nullable = false)
	@GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return this.id;
	}

	@Override
	public void setId(final int id) {
		this.id = id;
	}

	@Temporal(TemporalType.TIMESTAMP)
	@Column(name = "date", length = 19)
	public Date getDate() {
		return this.date;
	}

}
